perm filename SAVE[F8,ALS] blob sn#319424 filedate 1977-11-30 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00010 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	*CHECKERS as of November 28 1977.  EQU's
C00009 00003	  ORG  H'1780' SELE JUMP
C00024 00004	* NORM  FORE
C00038 00005	* RASC SCRA FKT STMV
C00043 00006	* NEXT  FIND  RFJ  LFJ  RBJ  LBJ
C00061 00007	* RFN LFN RBN LBN NORF NORT
C00068 00008	* AFT
C00079 00009	* EVAL
C00089 00010	* EMPT WAST BRAK STOP
C00097 ENDMK
C⊗;
*CHECKERS as of November 28 1977.  EQU's
* S2 section
*Resident package addresses
JOYT    EQU     H'0C00'
LINE    EQU     H'0FDF'
SHCB    EQU     H'0FE2'
INPF    EQU     H'0FE3'
WTLN    EQU     H'0FE5'
TXC     EQU     H'0FE8'
CMRG    EQU     H'0FEA'
DBNC    EQU     H'0FEB'
UPI     EQU     H'0FFA'
JOYI    EQU     H'21AD'
IJS     EQU     H'22DB'
SHL     EQU     H'27C6'
SHR     EQU     H'27D3'
PUSH    EQU     H'40A9'
POPS    EQU     H'40BC'
SPS     EQU     H'40D0'
WDG     EQU     H'4105'
WAUD    EQU     H'41C8'
WAU1    EQU     H'41CC'
CDS     EQU     H'41D5'
WMS     EQU     H'4205'
UDAT    EQU     H'424D'
TRAN    EQU     H'43CD'
FCS     EQU     H'43D6'
WAIT    EQU     H'4501'
TIR     EQU     H'45DB'
CLER    EQU     H'4762'
*Misc. constants
TCMD    EQU     H'44'
BCMD    EQU     H'6D'
TCOL    EQU     H'80'   TEXT COLOR
ULIN    EQU     H'F5'
COM     EQU     H'8F7'
*
*RAM assignments
BFLG    EQU     H'0C20'
BLNF    EQU     H'0C21'        Blink flag
XBLN    EQU     H'0C22'        X value to blink
YBLN    EQU     H'0C23'        Y value to blink
BCNT    EQU     H'0C24'        Counter used in OKMV
BKMV    EQU     H'0C25'        Data to index book moves
HSAV    EQU     H'0C26'        H save location
HSAL    EQU     H'0C27'        HL save location
PLY0    EQU     H'0C28'        Players choice of ply depth
COL0    EQU     H'0C29'        0 if machine plays black
SELX    EQU     H'0C2A'        Move count
AP20    EQU     H'0C2C'        ACTM+PASM+9 at HL=20
XOLD    EQU     H'0C2D'        X coord touch point (double jump)
YOLD    EQU     H'0C2E'        Y coord touch point (double jump)
CFLG    EQU     H'0C2F'        Compression flag for ply record
OBJ0    EQU     H'0C30'        Board 1, thru H'0E0F'
TREE    EQU     H'0E10'        Tree data, thru H'0EFF', Player's board first
TRE2    EQU     H'0E20'        Machine's first board here
TRE3    EQU     H'0E30'        PLY 1 location
TRE5    EQU     H'0E50'        PLY 3 location
PLMD    EQU     H'0E5B'        Used for temp store of player's move inf
PLMV    EQU     H'0ED0'        Overlay region used for player's moves
PLMF    EQU     H'0EE0'           and move numbers
SCOR    EQU     H'0EF0'        28 bytes for scores
XPOS    EQU     H'0F0C'        XPOSITION(CURSOR)
YPOS    EQU     H'0F0F'        YPOSITION(CURSOR)
OBJ1    EQU     H'0F10'        Board 2, thru H'0FAF'
MOBS    EQU     H'0FB0'         Mobility and DJ flags (14 bytes)
RGSV    EQU     H'0FC1'        Register save start (int. update)
*
*Scratch pad assignments
TEMP   EQU     H'8'
J      EQU     H'9'
HU     EQU     H'A'
HL     EQU     H'B'
PLOC   EQU     O'3'            LISU value for ACTIVE and PASSIVE
KLOC   EQU     O'4'            LISU value for KING's and special data
ELOC   EQU     O'5'            LISU value for EMPTY's area
ISA    EQU     O'30'           ISAR value for active area
ISP    EQU     O'34'           ISAR value for passive
ISK    EQU     O'40'           ISAR value for kings
ACTM   EQU     O'46'           Location of Active material count
PASM   EQU     O'47'           Location of Passive material count
ISE0   EQU     O'50'           ISAR value for guard byte
ISE    EQU     O'51'           ISAR value for empty (with offset)
*Mimimum ply depths
PLYT   EQU     H'FD'           Ply depth for Robot Tom (stored as neg.)
PLYD   EQU     H'FC'           Ply depth for Robot Dick
PLYH   EQU     H'FB'           Ply depth for Robot Harry
*SPECIAL CONSTANTS
MAT     EQU     0               As used in EVAL
POT     EQU     6
X       EQU     H'1'
Y       EQU     H'2'
VX      EQU     H'3'
VY      EQU     H'4'
CHT     EQU     H'3'    CURSOR HEIGHT
YTST    EQU     H'9'
XZOP    EQU     H'34'   Line for restorre of X zoom
MAXY    EQU     H'4D'   MAX Y COORD (=H'4F'-CHT)
*Linkage locations
PMOV    EQU     H'10F5'         Player's move
DJMP    EQU     H'1208'         Jump again entry
WMC     EQU     H'1225'         Write message
BORD    EQU     H'130D'         Normal redo of board
MWAD    EQU     H'162E'
ENIN    EQU     H'1656'
DAI     EQU     H'1673'
SHOW    EQU     H'171B'         Debugging aid to show board
  ORG  H'1780' SELE JUMP
*-*-*-
SELE    PI      SHOW
        PI      WAST            Debugging show board
        LISU    PLOC
        LISL    0
        LR      DC,H
        LIS     H'C'            To get MOVE byte
        ADC
        LM
        LR      0,A             Save it temporarily
        NS      0               To set status byte
        BNZ     SEL3
        JMP     NEXT            To get next MOVE byte
SEL3    CLR
        COM                     -1 in A
        ADC                     Get back to move byte
        AS      0
        NS      0               Remove right-most on-bit
        ST                      Put remaining bits back (and index)
        XS      0               This gets the extracted bit
        LR      6,A             Save it in 6
        LM                      Now get the byte designation
SEL4    LR      5,A
        SR      1
        SR      1
        NI      H'3'            Separate the byte indicator part
        LR      4,A             Save it in 4
        LR      A,5
        NI      H'13'           Separate the JUMP bit and the direction
        LR      5,A             Save them in 5
DELE    LI      ISA             Process Active and Kings for source deletion
        AS      4               Add byte #
        LR      IS,A            Get to initial byte
        LR      A,S
        LR      3,A
        XS      6               Delete moving piece
        LR      S,A             from byte
        LISU    KLOC            To get to corresponding KING byte
        LR      A,S
        NS      6               Was the piece a king?
        BZ      DEL2
        XS      S               If it was delete king bit
        LR      S,A
        LIS     H'7'            Non-zero in 2 for king 
DEL2    LR      2,A             0 for man, 7 for king, (later 1 for promotion)
        LISU    PLOC            Back to active section
*Now locate captured piece if jump or find destination in normal move
        LR      A,6             Recall MOVE bit
        SR      4
        BZ      INRH            Bit was in right half of byte
INLH    LR      3,A             Save partially shifted MOVE bit
        LIS     H'1'            Get direction
        NS      5               To test right-most bit
        BZ      INL2            RF or LB move where 4 shift is correct
        LR      A,3
        SR      1               LF and LB require an additional shift
        LR      3,A
INL2    LIS     H'2'            Now test for fore or aft
        NS      5   
        BZ      BOTH            Forward move, no byte shift needed
        LR      A,D             Only to decrement ISAR
INL3    BR      BOTH
*
INRH    LR      A,6             Get MOVE bit again
        SL      4               Left shift if in right half
        LR      3,A             Save partially shifted MOVE bit
        LIS     H'1'
        NS      5               Get direction
        BNZ     INR2            LF or LB where 4 shift is correct
        LR      A,3
        SL      1               RF and RB require an additional shift
        LR      3,A
INR2    LIS     H'2'            Now test fore and aft
        NS      5
        BNZ     BOTH
        LR      A,I             Only to increment ISAR
BOTH    LR      A,5             Now is this a jump or a normal move?
*ISAR still points to active region but may designate
*an empty square or the capture square
        SR      4               Set status for jump bit
        BNZ     JUMP
        JMP     NORM            It's a normal move
JUMP    LR      A,IS
        AI      H'4'            To get to passive pieces
        LR      IS,A
        LR      A,S
        XS      3               Remove captured piece
        LR      S,A
        LR      A,IS
        AI      H'4'            Corresponding king location
        LR      IS,A
        LR      A,S             Get byte
        NS      3               Is the piece a king?
        BZ      JUM1            No
        XS      S               Yes, Remove it
        LR      S,A
        LIS     H'2'
        COM                     Fast -3
        BR      JU11
JUM1    LIS     H'1'
        COM                     Fast -2
JU11    LR      0,A
        LI      PASM
        LR      IS,A
        LR      A,S
        AS      0
        LR      S,A
JU12    LI      ISA             Back to moved-from location
        AS      4               Byte number is in 4
        LR      IS,A
        LIS     H'2'
        NS      5               Test for fore or aft
        BZ      JUMA            Fore move
        LR      A,D             Decrement ISAR (destination always in next byte)
        BR      JUMB
JUMA    LR      A,I             Increment ISAR
JUMB    LR      A,IS            Get the destination byte off-set
        AI      H'E8'           by subtracting O'30' from ISAR value
        LR      4,A             needed if there is a continuation
        LIS     H'1'            Get direction
        NS      5               Test for right or left
        LR      A,6             Get original piece location
        BZ      JUM2            0 for R move, ≠0 for L move
        SR      1               Left moves involve a right shift of 1
        BR      JUM3
JUM2    SL      1               Right moves involve a left shift of 1
JUM3    LR      3,A             Save bit byte in 3, freeing 6 for other use
        LR      1,A             As mask in FIND for continuation
        LR      A,S
        XS      3               Set piece down
        LR      S,A
        CLR
        AS      2               Was the piece a king?
        BZ      JUMC            No, might be a promotion
        CLR
        LR      0,A             Temporary record of promotion credit
        BR     JUM6             Already a king so no promotion
JUMC    LIS     H'2'
        NS      5               Which side is active
        LR      A,IS
        BZ      JUM4            0 if forward
        CI      O'30'           Is this byte 0?
        BNZ     JU71            No, so no promotion
        LIS     H'F'            and the king row?
        SL      4
        BR      JUM5            Promotion indicated, no double jump
JUM4    CI      O'33'           Is this byte 3?
        BNZ     JU71            No, so no promotion
        LIS     H'F'            and the king row?
JUM5    NS      3
        BZ      JU71            No
        LIS     H'1'            1 for promotion
        LR      2,A             It was 0
        LR      0,A             Credit for promotion
        LR      6,A             Used in FIND for no continuation
JUM6    LISU    KLOC            Get to King position
        LR      A,S
        AS      3               Put down the king
        LR      S,A
        LR      A,0
        CI      H'1'            Was there a promotion?
        BZ     JU71             No
        LISU    4
        LISL    6
        LR      A,S
        INC                     Add for promotion
        LR      S,A
        BR      JUM9            Can be no continuation if promotion
JUM7    CLR
        XS      0               Should we check for a double jump?
        BZ     JU71             Yes, a 0 means no promotion
JUM9    JMP    FORE
* Set up conditions to try to find a continuation
JU71    LR      A,HL
        SR      4
        CI      H'C'            Is there room?
        BM      JUM9            No
        LR      DC,H
        LI      H'1C'           Get to byte location
        ADC                     in the "passed board" position
        LR      A,3             Save destination info
        ST                      the move byte
        LR      A,4
        ST                      and the byte #
        CLR
        COM                     and a flag of -1
        ST                      in the ACTM position
        LR      A,2             and # of moves in PASM
        LR      A,HL
        SR      4
        CI      H'1'            Is this a player's board?
        BNZ     JU79            No
        DCI     PLMV            Yes, restart PLMV
        CLR
        ST
        BR      JU77            and keep to this level
JU79    DCI     SCOR            Advance score
        AI      -H'2'           Scor not saved for HL=1
        SL      1
        ADC                     from current board
        LR      Q,DC
        XDC
        LR      DC,Q
        LIS     H'4'
        ADC
        XDC
        LM
        XDC
        ST
        XDC
        LM
        XDC
        ST
        LIS     H'2'            Copy data two blocks forward
        SL      4
        AS      HL
        LR      HL,A
JU77    LR      DC,H
        LISU    PLOC            SC to RA direct
        LISL    0
JU72    LR      A,I
        ST
        BR7     JU72
        LR      A,I
        ST
        LISU    KLOC
JU73    LR      A,I
        ST
        BR7     JU73
        LR      A,I
        ST
        PI      EMPT            Re-do to reflect changes
        LR      A,3             Save destination
        LR      1,A             as mask for FIND
        CLR
        LR      2,A
        LR      6,A
        JMP     RFJ             Find continuations if any
* NORM  FORE
*Now make normal move
NORM    LR      DC,H            Back in step
        CLR
        LR      0,A             Flag for no promotion
        LISU    PLOC            Get back to Active pieces
        LR      A,S             LISL still OK
        AS      3
        LR      S,A             Put in moved piece
        LR      A,2             Was it a king
        NS      2
        BNZ     NOM6            Yes so don't promote but do put king down
        LIS     H'2'
        NS      5               Test for direction
        LR      A,IS
        BZ      NOM4            Is it going forward?
        CI      O'30'           Did it get to the byte 0?
        BNZ     FORE            No
        LIS     H'F'           and in king row?
        SL      4
        BR      NOM5            Mark for promotion
NOM4    CI      O'33'           Did it get to byte 3?
        BNZ     FORE            No
        LIS     H'F'            and in king row?
NOM5    NS      3
        BZ      FORE            No
        LIS     H'1'
        LR      0,A             A promotion flag
NOM6    LISU    KLOC            Now get to king byte
        LR      A,S             Get corresponding king byte for destination
        AS      3               Insert king
        LR      S,A             And replace byte
        CLR
        AS      0
        BZ      FORE
        LI      ACTM            Get to active  material location
        LR      IS,A
        LR      A,S
        INC                     Credit for promotion
        LR      S,A
FORE    DCI     CFLG            Have we compacted?
        LR      Q,DC
        LM
        LR      0,A             Save value to add
        LR      DC,Q
        CLR                     and clear
        ST
        LR      A,HL            Where are we?
        SR      4
        CI      H'1'
        BNZ     FOR8
        JMP     FOR5            Player's move has been made
FOR8    PI      SHOW            DEBUGGING AID
        PI      WAST
        LR      A,7
        COM                     Change color
        LR      7,A
        LIS     H'1'
        SL      4
        AS      HL
        LR      HL,A
        LR      DC,H            GET back in step
        PI      SCRA            Prepare for normal advance
        LR      A,HL            Can we advance score?
        SR      4
        CI      H'3'            Note HL has already been advanced
        BM      FOR2            Advance score normally
        BNZ     FOR4            Special case
        DCI     SCOR+2
        LI      H'C1'
        ST
        INC
        ST
        BR      FOR4            May still be a special case
FOR2    AI      -H'2'           Scor not saved for HL=10
        SL      1               Scores take 2 bytes each so *2
        DCI     SCOR
        ADC                     Current location
        LR      Q,DC
        XDC
        LR      DC,Q
        LIS     H'3'
        COM                     Fast -H'4'
        ADC                     Get to earlier entry
        LM                      Copy it
        XDC
        ST
        XDC
        CI      H'C1'
        LM
        XDC
        BNZ     FOR7
        INC                     Add 2 for win or lose reporting
        INC
        AS      0
FOR7    ST
* Compacting routine to save space. Note this
* complicates reporting of win and lose distances.
        LR      A,HL
        SR      4
        CI      H'5'            Room to compact?
        BP      FOR3            No, let player make his next move
        AI      -H'4'           2 back in MOB
        DCI     MOBS            Compacting possible only if but
        ADC                     single moves available for 2
        LM                      successive moves
        CI      H'1'
        BNZ     FOR3            More than 1 move
        LM
        CI      H'1'
        BNZ     FOR3            More than 1 move
        LR      A,HL
        SR      4
        AI      -H'4'           Back 2 levels
        SL      1
        DCI     SCOR
        ADC
        LM
        CI      H'C1'
        BNZ     FORY
        LR      Q,DC
        LIS     H'2'
        AM
        LR      DC,Q
        ST
FORY    LIS     H'1'
        COM                     Back up 2 levels
        SL      4
        AS      HL
        LR      HL,A
        DCI     CFLG
        LIS     H'2'
        ST                      Set flag for SCOR check
        LR      DC,H            GET back in step
        PI      SCRA            Prepare for normal advance
FOR3    JMP     FIND            Go forward normally
FOR4    DCI     SELX
        LR      Q,DC
        LM
        CI      H'1'
        BM      FOR3            Normal play
        INC                     Book or random move has been made
        LR      DC,Q
        ST                      so count this as a move
        CLR                     Clear start of PLMV list for
        DCI     PLMV            listing player's possible moves
        ST
        LR      DC,H
        XDC
        DCI     TREE            Prepare for TRAN
        LR      H,DC
        LIS     H'1'
        SL      4
        LISU    2
        LISL    0
        LR      S,A
        PI      TRAN
        JMP     FIND            FIND exits to PMOV when HL is H'10'
FOR5    PI      BORD            Show board after players move
        LIS     H'4'            "MY MOVE"
        LR      0,A
        PI      WMC
        DCI     SCOR            Start scores off at H'C000'
        LI      H'C1'           so that CM's will always work
        ST
        ST
        ST
        INC
        ST
        LR      A,7
        COM                Change color
        LR      7,A
        LIS     H'1'
        SL      4
        AS      HL
        LR      HL,A
        LR      DC,H            Advance H
        PI      SCRA            SC to RA with sides reversed
        LR      DC,H
        PI      RASC            RA to SC preparing for a normal move
        DCI     SELX
        LR      Q,DC
        LM
        INC                     Add 1 to move count
        LR      DC,Q
        ST
        CI      H'1'
        BZ      FOR6            Use stored move
        JMP     FIND            Go find normal reply
FOR6    LISU    2               Get random number
        LISL    5
        LIS     H'3'
        NS      S               0 to 3 random number
        LR      0,A
        SR      1
        LR      1,A             0 to 1 random number
        LIS     H'1'
        NS      0   
        LR      0,A             2nd 0 to 1 random number
* Machine to make 2nd move from book
        DCI     BKMV            Get stored move munber
        LM
        SL      1               X2, 2 entries for each input move
        AS      0               Random choice between them
        DCI     BOK2            Stored table of book replies
        ADC
        LM                      Get reply number
        LR      0,A
        CLR                     Use second number to select which half
        XS      1
        LR      A,0
        BZ      BMV2
        SR      4
BMV2    NI      H'7'
        LR      0,A             The final selection
        DCI     REDM            Possible Red moves
BM17    LM                      Get byte record
        LR      1,A
BM18    LR      A,1
        NS      1
        BNZ     BM19            Is this byte exhausted?
        LM                      Step over byte info
        BR      BM17            Go to next byte record
BM19    LR      2,A
        AI      H'FF'           Subtract 1
        NS      1
        LR      1,A             byte less rightmost bit
        XS      2               This leaves 1 bit in A
        DS      0
        BP      BM18
        LR      6,A             Save the byte bit
        LM                      Get the byte info
        LR      4,A             The byte indicator
        LR      DC,H
        LIS     H'C'
        ADC
        LR      A,6
        ST
        LR      A,4
        ST
        JMP     SELE
*-*-*- Initial moves for red
REDM   DC      B'00000111'      3 pieces
       DC      B'00001010'      Byte 2, RB
       DC      B'00001111'      4 pieces
       DC      B'00001011'      Byte 2, LB
       DC      H'00'
* RASC SCRA FKT STMV
*-*-*- RASC RAM to SC transfer
RASC    LR      K,P             RAM to SC
        LISU    PLOC           ←SC buffer with Active and Passive
        LISL    0
RAS2    LM
        LR      I,A
        BR7     RAS2
        LM
        LR      I,A
        LISU    KLOC
RAS3    LM
        LR      I,A
        BR7     RAS3
        LM
        LR      I,A
        PK
*  SCRA  SC to RAM with side reversal
SCRA    LR      K,P             SC to RAM for side reversal
        LISU    PLOC
        LISL    4
        LIS     H'8'
        LR      0,A
SCR1    LR      A,I
        ST
        DS      0
        BNZ     SCR1
        LISU    KLOC
        LISL    0
        LIS     H'4'
        LR      0,A
SCR2    LR      A,I
        ST
        DS      0
        BNZ     SCR2
        CLR
        ST
        ST
        LISL    7
        LR      A,D
        ST
        LR      A,D
        ST
        PK
*-*-*- Test if Kings only can move
FKT     LR      K,P
        CLR
        AS      7
        BNZ     FK1             Only kings in this direction
FKT2    CLR
        XS      3
        PK                      Normal pieces OK
BKT     LR      K,P
        CLR
        AS      7             Test sides for backward move
        BNZ     FKT2             NORMAL pieces can move
FK1     LIS     H'2'
        SL      4
        AS      4
        LR      IS,A            KINGS only can move
        LR      A,S
        NS      3
        LR      3,A
        PK
*Subroutine to add to MOBILITY, and to store MOVE and FLAG bytes if necessary
STMV    LR      K,P
        LR      A,HL
        SR      4
        CI      H'01'           Is this the player's board
        BNZ     STM3            No
        DCI     PLMV            Player's moves stored separately
STM0    CLR
        XM
        BZ      STM1            Find empty space
        LM                      Skip info space
        BR      STM0            Try again
STM1    CLR                     Back up
        COM
        ADC
        LR      A,3
        ST
        LR      A,4
        SL      1
        SL      1
        AS      5
        ST
        CLR
        ST                      Store 0 as stop
        BR      STM2
STM3    CLR
        XS      2               To set status byte
        BNZ    STM2            One is already stored
        LR      DC,H            Get back in step (may not be necessary)
        LIS     H'C'            To get to MOVE byte
        ADC
STM4    LR      A,3
        ST                      Store MOVE byte in RAM
        LR      A,4             Get the byte pointer
        SL      1
        SL      1
        AS      5
        ST                      Put this into RAM
        LR      DC,H            May be necessary
STM2    CLR
        LR      0,A             To accumulate count
        LR      A,3
STM5    DS      0
        AI      H'FF'
        NS      3               Removes rightmost bit
        LR      3,A
        BNZ     STM5
        LR      A,0
        COM
        INC
        AS      2               Add in previous count
        LR      2,A
        PK
* NEXT  FIND  RFJ  LFJ  RBJ  LBJ
NEXT    PI      EMPT            Needs redoing if came to SELE via AFT
        LR      DC,H            
        LR      A,HL
        SR      4
        CI      H'3'
        BP      NEXX            Can not be a continuation
        LIS      H'3'           Look to earlier board data
        COM                     Fast -4
        ADC
        LM
        LR      1,A             Get move byte just in case
        LM
        LR      4,A             and byte info
        CLR     
        LR      2,A
        XM                      Now look at ACTM
        BP      NEXX            Not a continuation board
        LR      DC,H
        LIS     H'D'
        ADC
        LIS     H'3'            Get last used direction
        NM
        INC
        CI      H'3'
        BM      NEXY            Last direction used
        LR      5,A
        CLR
        COM
        LR      6,A             Set continuation flag
        JMP     RBJ0
NEXX    LR      DC,H
        LIS     H'D'            Last used byte info
        ADC
        LM
        LR      5,A
        NI      H'F'
        INC
        LR      0,A
        CI      H'F'            Is this the last byte and direction?
        BP      NEXA
NEXY    JMP     AFT             Yes, so back up
NEXA    LR      DC,H
        LIS     H'1'            Set to 1 for normal back-up
        LR      6,A
        CLR
        COM
        LR      1,A             All pieces allowed to move
        LR      DC,H
        LR      A,0
        SR      1
        SR      1
        NI      H'3'
        LR      4,A
        LR      A,5
        CI      H'F'
        LIS     H'3'
        BM      NEXJ            Jumps required
        NS      0
        LR      5,A
        BZ      NEN0
        JMP     RBN0
NEN0    JMP     RFN
NEXJ    NS      0
        LR      5,A
        BZ      NEJ0
        JMP     RBJ0
NEJ0    JMP     RFJ
*We enter here on going forward
FIND    LR      DC,H
        LR      A,HL
        SR      4
        CI      H'2'
        BNZ     FIN1
        LIS     H'E'            Compute ACTM+PASM+9
        ADC
        LIS     H'9'            Constant term
        AM
        AM
        DCI     AP20            Used by EVAL to compute MAT
        ST
        LR      DC,H
FIN1    PI      RASC            Get board into SC
        PI      EMPT            Compute the empty squares
        PI      SHOW
        PI      WAST
        CLR
        LR      4,A             Start with byte 0
        LR      2,A             Mobility count and move-found flag
        LR      6,A             So all moves will be found
        COM
        LR      1,A             To find all possible jump moves
RFJ     LI      ISA             Active pieces
        AS      4               Add byte off-set
        LR      IS,A            Get to byte
        LR      A,S
        NS      1               FF if normal, 1 bit only for continuation
        LR      3,A             3 used to develop final byte
        PI      FKT             Any forward moving pieces?
        BZ      RBJ             No, look to backward moving
        LI      ISE+1           Look to empty squares forward
        AS      4               Add byte off-set
        LR      IS,A            Destination byte location
        LR      A,S
        SR      1
        NS      3
        LR      3,A             Only pieces that have place to land
        LI      ISP             Passive pieces
        AS      4
        LR      IS,A
      LR      A,I            Look to RF passive pieces forward
      SL      4              In front of left-most bits
      LR      0,A
      LR      A,S
      SR      4              In front of right-most bits
      SR      1
      AS      0
      NS      3
      LR      3,A            Pieces that can jump RF
        BZ      LFJ          None was found
        LI      H'1'           The RFJ direction and J indicator
        SL      4
        LR      5,A
        PI      STMV            Store move byte and info
        CLR
        AS      6               Recall indicator
        BNZ     LFJ2
LFJ     LI      ISA
        AS      4               Add byte off-set
        LR      IS,A            Get to initial byte
        LR      A,S
        NS      1               FF if normal, 1 bit only for continuation
        LR      3,A
        PI      FKT
        LI      ISE+1           Empty squares forward
        AS      4
        LR      IS,A
        LR      A,S
        SL      1
        NS      3
        LR      3,A             Only pieces that have a place to land
        LI      ISP
        AS      4
        LR      IS,A
      LR      A,I
      SL      4
      SL      1
      LR      0,A
      LR      A,S
      SR      4
      AS      0
      NS      3
      LR      3,A             Pieces that can jump LF
        BZ      RBJ
        LI      H'11'           The LFJ direction and J indicator
        LR      5,A
        PI      STMV
        CLR
        XS      6
        BZ      RBJ
LFJ2    BR      RBJ2
RBJ0    LR      A,5
        CI      H'2'            Which direction, 1, 2, or 3?
        BM      LBJ             It was a 3
        BNZ     LFJ             It was a 1
RBJ     LI      ISA
        AS      4               Add byte off-set
        LR      IS,A            Get to initial byte
        LR      A,S
        NS      1               FF if normal, 1 bit only for continuation
        LR      3,A
        PI      BKT             Any backward moving pieces?
        BZ      FJ1            No
        LI      ISE-1           Look to empty squares backward
        AS      4
        LR      IS,A
        LR      A,S
        SR      1
        NS      3
        LR      3,A
        LI      ISP-1           Look to passive pieces backward
        AS      4
        LR      IS,A
      LR      A,I
      SL      4
      LR      0,A
      LR      A,S
      SR      4
      SR      1
      AS      0
      NS      3
      LR      3,A             Pieces that can jump RB
        BZ      LBJ
        LI      H'12'           The RBJ direction and J indicator
        LR      5,A
        PI      STMV
        CLR
        XS      6
RBJ2    BNZ     LBJ2
LBJ     LI      ISA
        AS      4               Add byte off-set
        LR      IS,A            Get to initial byte
        LR      A,S
        NS      1               FF if normal, 1 bit only for continuation
        LR      3,A
        PI      BKT
        LI      ISE-1           Empty squares backward
        AS      4
        LR      IS,A
        LR      A,S
        SL      1
        NS      3
        LR      3,A
        LI      ISP-1         Look to passive pieces backward
        AS      4
        LR      IS,A
      LR      A,I
      SL      4
      SL      1
      LR      0,A
      LR      A,S
      SR      4
      AS      0
      NS      3
      LR      3,A             Pieces that can jump LB
        BZ      FJ1
        LI      H'13'           The RBJ direction and J indicator
        LR      5,A
        PI      STMV
        CLR
        XS      6
        BZ      FJ2            We want them all
LBJ2    JMP     SELE            A successful NEXT
FJ1    CLR                      No backward moves
        XS      6
        BZ      FJ2             We want them all
        BP      FJ3            Try next byte
        JMP     AFT             A NEXT continuation failure
FJ2     LR      A,1             Was it a first continuation try?
        CI      H'FF'
        BNZ     FJ4             Yes
FJ3     LR      A,4             No, to next board byte
        INC
        NI      H'3'
        LR      4,A
        BZ      FJ9            There are no more
        JMP     RFJ             Go round again for next byte
FJ4     CLR                     A first continuation try
        XS      2               Was it successful?
        BZ      FJ5             No
* Successful continuation try
        LR      A,HL
        SR      4
        CI      H'5'            Where are we?
        BM      FJ7             Could be a second continuation
        CI      H'1'            A player's board
        BNZ     FJ10            No
        PI      BORD            Show board
        JMP     DJMP
* Unsuccessful continuation try
FJ5     LR      A,HL
        SR      4
        CI      H'1'            A player's board
        BM      FJ6             No
        JMP     FOR5            "MY MOVE" etc
FJ6     LIS     H'1'            Back 2 levels
        COM
        SL      4
        AS      HL
        LR      HL,A
        JMP     FORE
FJ7     LR      DC,H
        LIS     H'DE'           Back 3 levels at ACTM
        ADC
        CLR
        XM                      A previous continuation?
        BP      FJ10            No
        LM                      were there more than 2 moves?
        CI      H'1'
        BM      FJ8             Yes so save this one here
        LR      DC,H            No, so we can move data
        XDC                     back by 2 levels
        LIS     H'1'            and so save space
        COM                     A fast -2
        SL      4
        AS      HL
        LR      HL,A
        LR      DC,H
        LISU    2
        LISL    0
        LIS     H'2'
        SL      4
        LR      S,A
        PI      TRAN
FJ8     LR      A,HL
        SR      4
        CI      H'E'            Are we out of space?
        BZ      FJ12            Yes
        BR      FJ11
* All bytes exhausted
FJ9     CLR
        XS      2
        BNZ      FJ10           Jumps found
        CLR
        XS      6               Go to normal moves?
        BZ      RFN             Yes
        JMP     AFT             No more jumps
FJ10    LR      A,HL
        SR      4
        CI      H'E'
        BM      FJ12            Too bad, out of space
        CI      H'1'
        BNZ     FJ11             Not player's FIND
        PI      BORD            Show board with piece moved
        JMP     PMOV            Init cursor and say "MUST JUMP"
FJ11    AI      -H'2'
        DCI     MOBS
        ADC
        LR      A,2
        ST
        LR      DC,H            Prepare for continuation
        LI      H'1E'           To ACTM in passed board
        ADC                     These data are over-
        CLR                     written if no continuation
        COM                     A -1 signals 
        ST                      a continuation
        LR      A,2             A 1 here signals
        ST                      a single jump case
        JMP     SELE
FJ12    LISU    KLOC            Correct PASM and stop
        LISL    H'7'
        LIS     H'1'           Allow for a piece capture
        COM                    A fast -2
        AS      S
        LR      S,A
        JMP     EVAL
* RFN LFN RBN LBN NORF NORT
RFN     LI      ISA
        AS      4               Add byte off-set
        LR      IS,A            Get to initial byte
        LR      A,S
        LR      3,A
        PI      FKT
        BZ      RBN
        LI      ISE             Start of empty region
        AS      4               Add off-set
        LR      IS,A
      LR      A,I            Look to RF empty squares
      SL      4
      LR      0,A
      LR      A,S
      SR      4
      SR      1
      AS      0
      NS      3
      LR      3,A            Pieces that can move RF
        BZ      LFN
        CLR
        LR      5,A
        PI      STMV
        CLR
        XS      6
        BZ      LFN
        JMP     SELE
LFN     LI      ISA
        AS      4               Add byte off-set
        LR      IS,A            Get to initial byte
        LR      A,S
        LR      3,A
        PI      FKT
        BZ      RBN
        LI      ISE             Start of empty region
        AS      4               Add off-set
        LR      IS,A
      LR      A,I               Look to LF empty squares
      SL      4
      SL      1
      LR      0,A
      LR      A,S
      SR      4
      AS      0
      NS      3
      LR      3,A            Pieces that can move LF
        BZ      RBN
        LIS     H'1'
        LR      5,A
        PI      STMV
        CLR
        XS      6
        BZ      RBN
        JMP     SELE
RBN0    LR      A,5
        CI      H'2'            Which direction 1, 2 or 3?
        BM      LBN             It was a 3
        BNZ     LFN             It was a 1
RBN     LI      ISA
        AS      4               Add byte off-set
        LR      IS,A            Get to initial byte
        LR      A,S
        LR      3,A
        PI      BKT
        BZ      NORT
        LI      ISE-1
        AS      4               Add off-set
        LR      IS,A
      LR      A,I            Look to RB empty squares
      SL      4
      LR      0,A
      LR      A,S
      SR      4
      SR      1
      AS      0
      NS      3
      LR      3,A            Pieces that can move RB
        BZ      LBN          None can
        LIS     H'2'
        LR      5,A
        PI      STMV
        CLR
        XS      6
        BNZ     NORF
LBN     LI      ISA
        AS      4               Add byte off-set
        LR      IS,A            Get to initial byte
        LR      A,S
        LR      3,A
        PI      BKT
        BZ      NORT
        LI      ISE-1
        AS      4               Add off-set
        LR      IS,A
      LR      A,I               Look to LB empty squares
      SL      4
      SL      1
      LR      0,A
      LR      A,S
      SR      4
      AS      0
      NS      3
      LR      3,A            Pieces that can move LB
        BZ      NORT
        LIS     H'3'
        LR      5,A
        PI      STMV
        CLR
        XS      6
        BZ      NORT
NORF    JMP     SELE
*We get here if we want to compute mobility and also if no moves found
NORT    LR      A,4
        INC
        NI      H'3'
        LR      4,A
        BZ      NOR0
        JMP     RFN             Go round again for next byte
NOR0    CLR
        XS      2               Get mobility count
        BNZ     NOR1            Moves were found
        CLR
NORX    JMP     AFT
NOR1    LR      A,HL            Where are we?
        SR      4               Get Ply number
        AI      -H'1'
        BNZ     NOR2            Checking for possible player's moves?
        PI      BORD            Put up board for player
        JMP     PMOV            Yes, so let him move
NOR2    DCI     PLY0            Player's choice of ply
        AM
        LR      DC,H            Reset DC
        BM      NOR4            Go on in this case
        BNZ     NOR3            Stop for sure
        LI      H'FD'           Decision based on previous move
        ADC
        LM
        NI      H'10'           Test jump flag
        BNZ     NOR4            Go on if previous move was a jump
NOR3    JMP     EVAL
NOR4    LR      A,HL
        SR      4
        AI      -H'2'
        BM      NOR7
        DCI     MOBS
        ADC
        LR      A,2
        ST                      Save mobility in MOBS space indexed by ply
NOR7    JMP     SELE
* AFT
*MAT     EQU     H'0'            Register used for Material Adv. term
*POT     EQU     H'6'            Register used for Positional Adv. term
*Defined earlier
HLS     EQU     H'4'            Register to save HL off-set
*No more moves found so time to back up
AFT     LR      A,HL            Prepare to back up
        SR      4
        CI      H'2'
        BNZ     AFT0            Not at end of tree search
*Prepare for verification of player's reply
        AI      H'FF'           Back to player's board
        SL      4
        LR      HL,A
        LR      A,7
        COM                     Reverse sides
        LR      7,A
        DCI     PLMV            This space is also used by TREE routine
        CLR                     Clear first byte
        ST
        JMP     FIND            Get verification info for move
AFT0    AI      -H'2'           SCOR not saved for HL=10
        SL      1               2 bytes per entry
        DCI     SCOR
        ADC
        LR      Q,DC            We'll use this as reference point
        LM
        LR      MAT,A             The current material advantage term
        LM
        LR      POT,A             The current positional term
        LR      A,HL
        CI      H'30'
        BNZ     AFTE            Must test for double jump and continuation
        LR      DC,Q            HL=30 case
        LIS     H'1'
        COM                     Fast way for -2
        ADC
        LR      Q,DC
        LR      A,POT
        COM                     Make negative
        INC
        LR      POT,A
        LR      A,MAT
        COM
        INC
        LR      MAT,A
        CM
        BM      AF3S            Back score for sure
        BNZ     AF3B            Do not back score
        LR      A,POT
        CM
        BP      AF3B            Do not back score
AF3S    LR      DC,Q            Backing score
        LR      A,MAT
        ST
        LR      A,POT
        ST
        LR      DC,H            and saving board
        XDC
        DCI     TREE
        LISU    2
        LISL    0
        LIS     H'1'
        SL      4               Fast H'10'
        LR      S,A
        PI      TRAN
AF3B    JMP     AF1B            Back level by 1
* HL>30 case
AFTE    LR      DC,H            EVAL enters here
        LIS     H'1'            Neg. ACTM for passed board
        COM                     Fast -2
        ADC
        CLR
        XM                      Is -1 board passed
        BM      AFC1            Yes
        LI      H'EF'           Is -2 board passed 
        ADC
        CLR
        XM
        BM      AFN3            Yes
* -1 and -2 boards not passed
        LIS     H'3'            Try to prune
        COM                     Fast -H'4'
        LR      DC,Q
        ADC
        LR      A,MAT
        CM
        BM      AFN3            Can not prune
        BNZ     AFN2            Can prune
        LR      A,POT           MAT's are equal
        CM
        BM      AFN3            Can not prune
AFN2    JMP     AF2B            To back 2 levels
AFN3    LIS     H'1'            No, try normal back up
        COM                     Fast -H'2'
        LR      DC,Q
        ADC
        LR      Q,DC
        LR      A,POT           with neg. scores
        COM
        INC
        LR      POT,A
        LR      A,MAT
        COM
        INC
        LR      MAT,A
        CM
        BM      AFN4            Do back score
        BNZ     AFN5            Don't back score
        LR      A,POT           Try POT terms
        CM
        BP      AFN5            Don't back score
AFN4    LR      DC,Q            Backing score
        LR      A,MAT
        ST
        LR      A,POT
        ST
AFN5    JMP     AF1B            To back 1 level
* -1 board is passed so this was a multiple jump
AFC1    LR      A,HL
        NI      H'10'           Is HL odd?
        BNZ     AFD1            Yes, may want to save board
* HL is even case, so board should not be saved
AFE1    LIS     H'3'            Should back 2 however
        COM                     Fast -H'4'
        LR      DC,Q            Check on score
        ADC
        LR      Q,DC
        LR      A,MAT
        CM
        BM      AFE2            Should back score
        BNZ     AFE3            Should not back score
        LR      A,POT           Must check POT term
        CM
        BP      AFE3            Should not back score
AFE2    LR      DC,Q            Back score
        LR      A,MAT
        ST
        LR      A,POT
        ST
AFE3    JMP     AF2B            To back 2 levels
* HL is odd, may need to save board
AFD1    LI      H'DE'           We may want to save board
        LR      HLS,A           Check on board back 3 levels
AFD2    LR      DC,H
        ADC                     Back to start of continuation
        CLR
        XM
        BP      AFD3            As far as we can go
        LIS     H'E'
        SL      4               Fast H'E0'
        AS      HLS
        LR      HLS,A
        BR      AFD2
AFD3    LR      A,HLS
        SR      4
        CI      H'2'            Back to HLS=2E
        BNZ     AFE1            Handle as if HL was even
        DCI     SCOR+2          Compare score with HL=30 level
        LR      A,MAT
        CM
        BM      AFD4            Maybe should back
        BNZ     AF2B            Should back only 2 levels
        LR      A,POT
        CM
        BP      AF2B            Back 2 levels without score
AFD4    DCI     SCOR            Now compare with HL=20 level
        LR      A,POT           after sign change
        COM
        INC
        LR      POT,A
        LR      A,MAT
        COM
        INC
        LR      MAT,A
        CM
        BM      AFD5            Back score
        BNZ     AF2B            No, just back 2 levels
        LR      A,POT
        CM
        BP      AF2B            Just back 2 levels
AFD5    DCI     SCOR            Now save scores
        LR      A,MAT
        ST
        LR      A,POT
        ST
        LR      DC,H            and save board at TREE
        XDC
        DCI     TREE
        LISU    2
        LISL    0
        LIS     H'1'
        SL      4               Fast H'10'
        LR      S,A
        PI      TRAN
AF2B    LIS     H'E'            Back 2 levels
        SL      4               Fast H'E0'
        BR      AFBB
AF1B    LR      A,7             Reverse sides and back 1 level
        COM
        LR      7,A
        LIS     H'F'            Back 1 level
        SL      4               Fast H'F0'
AFBB    AS      HL
        LR      HL,A
        LR      DC,H
        PI      RASC
        DCI     CFLG
        CLR
        ST                      Clear compacting flag
        JMP     SELE
* EVAL
* HLS used temporarily in multiply routine
EVAL    LISU    4                 Compute the material advantage term
        LISL    6                 Get to ACTM
        LR      A,I
        LR      MAT,A             ACTM
        LR      A,I
        LR      HLS,A             PASM
        COM
        INC
        AS      MAT
        LR      3,A             ACTM-PASM
        BP      EVA0
        COM
        INC
EVA0    LR      1,A             |A-P|
        LR      A,MAT
        AS      HLS             A+P
        COM
        INC                     -(A+P)
        DCI     AP20
        AM                      Add initial value +6
        SR      1               and divide by 2
        LR      HLS,A           Save temporarily, multiply by
        CLR                     by smaller pos. # in 1
        LR      MAT,A             Product into MAT
        LR      A,1
EVA1    NI      H'1'            Is the rightmost bit a 1?
        BZ      EVA2            No
        LR      A,HLS
        AS      MAT
        LR      MAT,A
EVA2    LR      A,HLS
        SL      1
        LR      HLS,A
        LR      A,1
        SR      1
        LR      1,A
        BNZ     EVA1            Product is not complete
        LR      A,MAT
        CI      H'33'           Maximum of 51
        BP      EV21
        LI      H'33'           Limit range to avoid CM trouuble
        LR      MAT,A
EV21    CLR
        XS      3               To get sign
        LR      A,MAT
        BP      EVA3
        COM
        INC
        LR      MAT,A             Material advantage with sign
* Compute guard row credit
        LISU    PLOC
        CLR
        LR      3,A
        XS      7
        BZ      EVG2            Black is active
        LISL    4               Passive's (black's) guard byte
        LIS     H'A'
        SL      4               Passive's guard bits
        NS      S               Are pieces there?
        LR      1,A
        AI      H'FF'
        NS      1               Both of them?
        BZ      EVG1            No
        CLR
        COM                     Debit 
        LR      3,A
EVG1    LISL    3               Active's (red's) guard byte
        LIS     H'5'            Active's guard bits
        NS      S               Are pieces there?
        LR      1,A
        AI      H'FF'
        NS      1               Both of them?
        BZ      EVG4            No
        LR      A,3
        INC
        LR      3,A             Credit
        BR      EVG4
EVG2    LISL    7               Passive's (red's) guard byte
        LIS     H'5'
        NS      S               Are pieces there?
        LR      1,A
        AI      H'FF'
        NS      1               Both of them?
        BZ      EVG3            No
        CLR
        COM                     Debit
        LR      3,A
EVG3    LISL    0               Active's (black's) guard byte
        LIS     H'A'
        SR      4               Active's guard bits
        NS      S               Are pieces there?
        LR      1,A
        AI      H'FF'
        NS      1               Both of them?
        BZ      EVG4            No
        LR      A,3
        INC                     Credit
        LR      3,A
EVG4    LR      A,3
        SL      1               Credit of 2, 0 or -2
        AS      MAT             Add to MAT
        LR      MAT,A
* Center credit
        CLR
        LR      3,A
        LISL    5               Start with passive 
EVD0    LI      H'66'           These squares
        NS      I               Are they occupied?
        BZ      EVD2            No
EVD1    LR      1,A             Count them
        DS      3
        CLR
        COM
        AS      1
        NS      1
        BNZ     EVD1
        LR      A,IS
        NI      H'1'            Can we consider next byte?
        BZ      EVD0            Yes
EVD2    LR      A,3
        AS      MAT             Debit for passive occupancy
        LR      MAT,A
        CLR
        LR      3,A
        LISL    1               Now for active's bytes
EVD3    LI      H'66'           These squares
        NS      I               Are they occupied?
        BZ      EVD6            No
EVD5    LR      1,A             Count them
        DS      3
        CLR
        COM
        AS      1
        NS      1
        BNZ     EVD5
EVD6    LR      A,IS
        NI      H'1'            Can we consider the next byte?
        BZ      EVD3            Yes
EVD8    LR      A,3
        COM
        INC                     Credit for active occupancy
        AS      MAT
        LR      MAT,A
* Now the second SCOR term
EVA3    LR      A,HL
        SR      4
        AI      -H'2'
        LR      5,A             Save PLY
        DCI     MOBS            Compute mobility term
        AI      -H'1'
        ADC
        LM                      Get earlier mobility
        COM
        INC
        AS      2               Add current mobility
        CI      H'C'            Difference limited to |12|
        BP      EVA4
        LIS     H'C'
EVA4    CI      -H'C'
        BM      EVA5
        LI      -H'C'
EVA5    SL      1               Make room for ply term
        SL      1               Would like to shift more
        LR      POT,A           Save difference (and free 2)
        CLR
        AS      MAT
        BNZ     EVA6
        CLR     
        AS      POT
EVA6    LR      A,5             Get ply value
        BM      EVA7            Test sign of significant term
        COM                     If pos. we add H'C'-PLY
        INC
        AI      H'C'
        BR      EVA8
EVA7    AI      -H'C'           If neg. we add PLY-H'C'
EVA8    AS      POT             Add it in
        LR      POT,A           Positional term with PLY
EVA9    LR      A,HL
        SR      4
        AI      -H'2'
        SL      1
        DCI     SCOR
        ADC
        LR      Q,DC
        JMP     AFTE            AFT routine handles from here on
* EMPT WAST BRAK STOP
EMPT    LR      K,P             Empty squares in O'51' thru O'54'
        LISU    ELOC            with guard bytes in 50 and 55
        LISL    0
        CLR
        LR      S,A             Make sure guard byte is empty
        LISU    PLOC            Start with ACTIVE
        LIS     H'4'
        LR      0,A
        BR      EMP3
EMP2    LR      A,IS
        AI      H'30'           Actually subtracting 16
        LR      IS,A
EMP3    LR      A,S
        LR      1,A
        LR      A,IS
        AI      4
        LR      IS,A
        LR      A,S
        AS      1
        LR      1,A
        LR      A,IS
        AI      H'D'            Add 13 get to the correct EMPTY locat
        LR      IS,A
        LR      A,1
        COM                     Reverse 1's and 0's
        LR      S,A
        DS      0
        BNZ     EMP2
        LR      A,I             To index only
        CLR
        LR      S,A             Upper guard byte
        PK
*-*-*-*-*-*-*-*-*-*
*First replies (maximum of 4 each)
BOK2    DC      H'33'   24,20  24-20    To 12-16
        DC      H'33'   24-20, 24-20
        DC      H'43'   23-19, 24-20    To 11-15
        DC      H'20'   22-17, 24-19
        DC      H'22'   22-17, 22-17    To 10-14
        DC      H'22'   22-17, 22-17
        DC      H'55'   22-18, 22-18    To  9-13
        DC      H'55'   22-18, 22-18
        DC      H'31'   24-20, 23-18    To 11-16
        DC      H'45'   24-19, 22-18
        DC      H'66'   21-17, 21-17    To 10-15
        DC      H'66'   21-17, 21-17
        DC      H'55'   22-18, 22-18    To  9-14
        DC      H'55'   22-18, 22-18
*-*-*-
WAST    LR      K,P        Delay loop to WASTE some time
WAS2    LIS     H'F'
        LR      1,A
WAS3    CLR
        LR      2,A
WAS4    DS      2
        BNZ     WAS4
        DS      1
        BNZ     WAS3
        PK
*
BRAK    LR      A,HL
        SR      4
        DCI     H'0C2B'
        CM
        BZ      BRA2
        JMP     SELE
BRA2    NOP
        NOP
        NOP
        NOP
STOP    DCI     SCOR            What kind of score?
        LM
        CI      H'3F'           Does the machine have a win?
        BNZ     STO1            No
        LM                      Yes, at what ply?
        COM
        INC
        LR      2,A
        LIS     H'7'            "I can win in "
        BR      STO2
STO1    CI      H'C1'           Does player have a win?
        BNZ     STO4            No
        LM                      Yes, at what ply?
        LR      2,A
        LIS     H'8'            "You can win in "
STO2    PI      WMC             Write message
        PI      DAI             Disable interruupts
        PI      MWAD            Wait then update
        LR      A,2
        AI      H'3F'
        LR      TEMP,A
        PI      WDG             Report ply
        PI      MWAD            Wait then update
        PI      ENIN            Enable interrupts
        CLR
        LR      3,A
STO3    PI      WAST            Leave message up awhile
        DS      3
        BNZ     STO3
        LR      A,2
        CI      H'2'            Early warning only?
        BM      STO4            Yes
        JMP     H'4000'         Stop
STO4    JMP     PMOV
        DC      0
        DC      0
        DC      0
        DC      0
        END
*-*-*-
*First counter replies (maximum of 2 each)
*NOTE This table will not work as there are 28 possible third move
*nombers that have to be stored and this will take a complete byte for each
*thus requiring 98 bytes for this table.
*
BOK3    DC                              To 12-16 24-19
        DC                              To 12-16 23-18
        DC                              To 12-16 22-17
        DC      H'00'    8-12,  8,12    To 12-16 24-20
        DC      H'00'   16-23, 16,23    To 12-16 23-19
        DC                              To 12-16 22-18
        DC                              To 12-16 21-17
        DC      H'00'   15-24, 15-24    To 11-15 24-19
        DC      H'00'    8-11,  8-11    To 11-15 23-18
        DC      H'60     9-13,  8-11    To 11-15 22-17
        DC      H'00'    8-11,  8-11    To 11-15 24-20
        DC      H'05     8-11,  9-14    To 11-15 23-19
        DC      H'00'   15-22, 15-22    To 11-15 22-18
        DC                              To 11-15 21-17
*-*- THERE WILL BE 49 BYTES OF THESE, EACH WITH 2 COUNTER REPLIES
*-*- The ones listed at present are from Lee's Guide
*       END